package com.jams.goodox.entity.resp;

import android.text.TextUtils;

import com.jams.goodox.entity.Mapper;
import com.jams.goodox.entity.ParkOrderDetailBodyBean;
import com.jams.goodox.entity.ServeOrderDetailBean;
import com.jams.goodox.net.BaseEntity;
import com.jams.goodox.utils.StringUtils;
import com.jams.goodox.utils.Utils;

import java.util.ArrayList;

/**
 * 停车申请订单详情页
 * Created by guozhen.hou on 2017/7/11.
 */

public class ParkOrderDetailResp extends BaseEntity{
    private OrderDetailResp data;

    public OrderDetailResp getData() {
        return data;
    }

    public void setData(OrderDetailResp data) {
        this.data = data;
    }

    public static class OrderDetailResp implements Mapper<ServeOrderDetailBean>{
        private String busId;
        private String buyNum;
        private String carNum;
        private String carPlaceRuleId;
        private String communityId;
        private String communityName;
        private String endTime;
        private String enterpriseHouseId;
        private String enterpriseHouseName;
        private String enterpriseId;
        private String enterpriseName;
        private String identity;
        private String intime;
        private String inuser;
        private String invoiceName;
        private String invoiceType;
        private String isAuthority;
        private String isPay;
        private String isStatus;
        private String menuCost;
        private String menuType;
        private String mobileNum;
        private String moneyType;
        private String orderId;
        private double orderMoneyReal;
        private double orderMoneyTotal;
        private String orderNum;
        private String orderRemark;
        private String orderStatus;
        private String orderType;
        private String payNo;
        private Object payTime;
        private String placeType;
        private String pubobj;
        private String redPacketId;
        private String redPacketMoney;
        private String referTime;
        private String sex;
        private String startTime;
        private String subId;
        private String subName;
        private Object updateTime;
        private String updateUser;
        private String userId;
        private String userName;
        private String userType;
        private String waitPayTime;
        private String subPhone;
        private ArrayList<Integer> payType;
        @Override
        public ServeOrderDetailBean transform() {
            ServeOrderDetailBean serveOrderDetailBean=new ServeOrderDetailBean();
            serveOrderDetailBean.setOrderStatus(orderStatus);
            serveOrderDetailBean.setOrderNumber(orderNum);
            serveOrderDetailBean.setEmptyPayTime(waitPayTime);
            serveOrderDetailBean.setSubmitOrderTime(referTime);
            serveOrderDetailBean.setServicePhone(mobileNum);

            ServeOrderDetailBean.CompanyAddressBean companyAddressBean=new ServeOrderDetailBean.CompanyAddressBean();
            companyAddressBean.setCompanyAddress(enterpriseHouseName);
            companyAddressBean.setCompanyName(enterpriseName);
            companyAddressBean.setOperatorName(userName);//下单人
            companyAddressBean.setOperatorPhone(mobileNum);//操作人电话
            serveOrderDetailBean.setCompanyAddressBean(companyAddressBean);
            serveOrderDetailBean.setChoosePayTypeList(payType);

            ServeOrderDetailBean.PersonAddressBean personAddressBean=new ServeOrderDetailBean.PersonAddressBean();
            personAddressBean.setConsigneeAddress(enterpriseHouseName);//个人订单收货地址
            personAddressBean.setConsigneePeople(userName);
            personAddressBean.setConsigneePhone(mobileNum);//电话号码
            serveOrderDetailBean.setPersonAddressBean(personAddressBean);

            ParkOrderDetailBodyBean parkOrderDetailBodyBean=new ParkOrderDetailBodyBean();
            parkOrderDetailBodyBean.setRemark(TextUtils.isEmpty(orderRemark)?"无":orderRemark);
            parkOrderDetailBodyBean.setBuyNumber(buyNum);
            parkOrderDetailBodyBean.setCarNumber(carNum);
            parkOrderDetailBodyBean.setPriceUnit(String.format("%s元/%s", Utils.getIntByStr(menuCost),"2".equalsIgnoreCase(menuType)?"月":"年"));
            parkOrderDetailBodyBean.setUseDateTime(String.format("%s~%s",startTime,endTime));
            serveOrderDetailBean.setServeDetail(parkOrderDetailBodyBean);
            parkOrderDetailBodyBean.setServiceName(subName);

            serveOrderDetailBean.setTotalMoney(orderMoneyTotal);
            serveOrderDetailBean.setRealMoney(orderMoneyReal);
            serveOrderDetailBean.setPayType(moneyType);
            serveOrderDetailBean.setIsPay(isPay);
            serveOrderDetailBean.setRedPacketMoney(StringUtils.toDouble(redPacketMoney));

            serveOrderDetailBean.setInvoiceType(invoiceType);
            serveOrderDetailBean.setInvoiceHead(invoiceName);

            serveOrderDetailBean.setServicePhone(subPhone);

            return serveOrderDetailBean;
        }
    }
}
